﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Scala.Logic.Services
{
    public class InputStringsService
    {
        public bool VerefyLenght(int minLenght, int maxLenght, string validationString)
        {
            return validationString.Length >= minLenght && validationString.Length <= maxLenght;
        }

        public bool VerifByRegexPattern(string value, string pattern)
        {                        
            return Regex.IsMatch(value, pattern);
        }

        public bool VerifyStartsSymbolWithRegexpPattern(string value, string pattern)
        {
            return VerifByRegexPattern(value.First().ToString(), pattern);
        }

        public bool VerifyCyrillicWithSpace(string value)
        {
            var pattern = @"^[а-яА-Я' ']+$";
            return VerifByRegexPattern(value, pattern);
        }

        public bool ValidateEventTitleFacade(string title)
        {
            return !String.IsNullOrEmpty(title) && VerefyLenght(3, 200, title)
                && !VerifyStartsSymbolWithRegexpPattern(title, @"\p{P}");
        }

        public bool ValidateEventPlaceFacade(string place)
        {
            return !String.IsNullOrEmpty(place) && VerifyCyrillicWithSpace(place);
        }
    }
}
